package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import java.util.ArrayList;
import java.util.List;

public enum TimeIntervalTypeEnum {

    NO_LOOP("noLoop", "enum.timeIntervalType.name.no_loop", 0),
    DAY("day", "enum.timeIntervalType.name.day", 1),
    WEEK("week", "enum.timeIntervalType.name.week", 2),
    MONTH("month", "enum.timeIntervalType.name.month", 3),
    YEAR("year", "enum.timeIntervalType.name.year", 4),
    UNKNOWN_TYPE("unknown", "enum.timeIntervalType.name.unknown_type", 404);

    //可更改的字段


    /**
     * 枚举描述 --英文名称
     */
    private final String alias;

    /**
     * 枚举信息--中文名称
     */
    private final String name;

    /**
     * 枚举值 --
     */
    private final int code;

    /**
     * 构造一个<code>ApprovalEnum</code>枚举对象
     *
     * @param code
     * @param name
     * @param alias
     */
    private TimeIntervalTypeEnum(String alias, String name, int code) {
        this.alias = alias;
        this.name = name;
        this.code = code;
    }

    /**
     * @return Returns the code.
     */
    public int getCode() {
        return code;
    }

    /**
     * @return Returns the name.
     */
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    /**
     * @return Returns the alias.
     */
    public String getAlias() {
        return alias;
    }

    /**
     * 获取全部枚举
     *
     * @return List<CustomerEnum>
     */
    public static List<TimeIntervalTypeEnum> getAllEnum() {
        List<TimeIntervalTypeEnum> list = new ArrayList<TimeIntervalTypeEnum>();
        for (TimeIntervalTypeEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取可以更改的字段
     *
     * @return
     */
    public static List<TimeIntervalTypeEnum> getModifyEnum() {
        List<TimeIntervalTypeEnum> list = new ArrayList<TimeIntervalTypeEnum>();
        for (TimeIntervalTypeEnum cache : values()) {
            if (1 == cache.getCode()) {
                list.add(cache);
            }
        }
        return list;
    }

    /**
     * 获取全部枚举值
     *
     * @return List<String>
     */
    public static List<String> getAllEnumAlis() {
        List<String> list = new ArrayList<String>();
        for (TimeIntervalTypeEnum cache : values()) {
            list.add(cache.getAlias());
        }
        return list;
    }

    /**
     * 获取全部枚举code
     *
     * @return List<Integer>
     */
    public static List<Integer> getAllEnumCode() {
        List<Integer> list = new ArrayList<Integer>();
        for (TimeIntervalTypeEnum cache : values()) {
            list.add(cache.getCode());
        }
        return list;
    }

    /**
     * 获取全部枚举name
     *
     * @return List<String>
     */
    public static List<String> getAllEnumName() {
        List<String> list = new ArrayList<String>();
        for (TimeIntervalTypeEnum cache : values()) {
            list.add(cache.getName());
        }
        return list;
    }

    /**
     * 通过枚举<code>code</code>获得枚举
     *
     * @param code
     * @return WxErrorCodeEnum
     */
    public static TimeIntervalTypeEnum getByCode(Integer code) {
        for (TimeIntervalTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN_TYPE;
    }
}
